package agenda.datos;

    import java.io.BufferedReader; 
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    //import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.util.ArrayList;


public class GuardarDatos {
 
        private static final String NOMFITX = "Agenda.txt";
        private String cadena ;
        
        public void procesar (AgendaEx miAgenda) {

    	 
     	   
    	   PrintWriter pw = null ;
    	   try {
    	      pw = new PrintWriter (NOMFITX) ;
    	      
    	      ArrayList<Entrada> listaEntrada = miAgenda.listarEntradas();
    	      if (listaEntrada == null) {
    	      	    System.out.println("No hay entradas.");
    	      	} else {
    	      	    for (Entrada e:listaEntrada) {
    	      		if (e!=  null ) {
    	      		    pw.println(e.toFichero());
    	      		 }
    	      	    }
    	      	}	      
    	      }
    	   catch (ExcepcionAgendaVacia eav){
    	               
    	    } 
    	   catch (FileNotFoundException fne){
                   
    	    }finally {
    	      if (pw != null)
    		 pw.close () ;
    	    }
        }

    }


